<%@page import="weaver.conn.RecordSet"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="com.zlgs.cqyf.vote.ConnectionUtil"%>
<%@ page import="java.io.PrintWriter" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%
    response.setCharacterEncoding("UTF-8");
    response.setContentType("application/json; charset=utf-8");
    JSONObject retObject = new JSONObject();
    retObject.put("code", 200);
    retObject.put("msg", "操作成功");
    try {
        // URL 参数
        Object ids  = request.getParameter("ids");                                    // 提名ids,逗号隔开
        Object awards_subname_id  = request.getParameter("awardsSubnameId");         // 奖项配置id
        //将子奖项信息设置为发布获奖
        String updateString =" update vote_awards_subname set status =2  where id = "+ awards_subname_id.toString();
        RecordSet set0  = new RecordSet();
        set0.executeSql(updateString);
        // 插入数据
        // 清除历史设置
        String sql = "update vote_awards_participator set win_status=0  where awards_subname_id = "+awards_subname_id.toString();
        RecordSet set  = new RecordSet();
        set.executeSql(sql);
        // 重新设置获奖
        sql = "update vote_awards_participator set win_status=1,update_time=GETDATE() where id in ("+ids.toString()+")";
        RecordSet set1  = new RecordSet();
        set1.executeSql(sql);
    } catch (Exception e) {
        e.printStackTrace();
        retObject.put("code", -1);
        retObject.put("msg", e.getMessage());
    } finally {
        PrintWriter printWriter = response.getWriter();
        printWriter.append(retObject.toJSONString());
        if (printWriter != null)  printWriter.close();
    }
%>
